﻿using System;
using System.Collections.Generic;
using System.Text;
using SecurityDAL;
using System.Data;
using Model.Security.FindEntityInfo;
using MyExection;
using Model.Security.EntityInfo;

namespace SecurityBLL
{
    public class DeptBLL
    {
        private DeptDAL deptDAL = null;
        public DeptBLL()
        {
            deptDAL = new DeptDAL();
        }
        /// <summary>
        /// 根据实体获取部门信息
        /// </summary>
        /// <param name="findEntity"></param>
        /// <returns></returns>
        public DataTable SearchByEntity(FindDept findEntity)
        {
            try
            {
                return deptDAL.SearchByEntity(findEntity);
            }
            catch (CustomException)
            {
                throw new CustomException("根据实体获取部门信息出错，请重试！");
            }
        }
        /// <summary>
        /// 获取部门信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetBuMen()
        {
            try
            {
                return deptDAL.GetBuMen();
            }
            catch (CustomException)
            {
                throw new CustomException("获取部门信息出错，请重试！");
            }
        }
        /// <summary>
        /// 根据部门id获取部门详细信息
        /// </summary>
        /// <param name="BM_ID"></param>
        /// <returns></returns>
        public Dept GetListDetailById(int BM_ID)
        {
            try
            {
                return deptDAL.GetListDetailById(BM_ID);
            }
            catch (CustomException)
            {
                throw new CustomException("根据部门id获取部门详细信息出错，请重试！");
            }
        }
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="entityInfo"></param>
        /// <returns></returns>
        public bool InsertDept(Dept entityInfo)
        {
            try
            {
                return deptDAL.InsertDept(entityInfo);
            }
            catch (CustomException)
            {
                throw new CustomException("添加部门出错，请重试！");
            }
        }
        /// <summary>
        /// 更新部门信息
        /// </summary>
        /// <param name="entityInfo"></param>
        /// <returns></returns>
        public bool UpdateDept(Dept entityInfo)
        {
            try
            {
                return deptDAL.UpdateDept(entityInfo);
            }
            catch (CustomException)
            {
                throw new CustomException("更新部门信息出错，请重试！");
            }
        }
        /// <summary>
        /// 删除部门信息
        /// </summary>
        /// <param name="BM_ID"></param>
        /// <returns></returns>
        public bool DeleteDept(int BM_ID)
        {
            try
            {
                return deptDAL.DeleteDept(BM_ID);
            }
            catch (CustomException)
            {
                throw new CustomException("删除部门信息出错，请重试！");
            }
        }
    }
}
